import { API } from '../config/http.config';
import { get, post, del } from './request';

export function getHotProducts(options = {}) {
    return get(API.getHotProducts, options);
}

export function getBanners(options = {}) {
    return get(API.getBanners, options);
}

export function getCategories(options = {}) {
    return get(API.getCategories, options);
}


export function getProducts(options = {}) {
    console.log('getProducts接收到的参数:', options);
    // 确保params正确传递
    return get(API.getProducts, {
        params: options
    });
}

export function getProductDetailById(options = {}) {
    return get(API.getProductDetailById, options);
}

export function addOrder(data, options = {}) {
    return post(API.addOrder, data, options);
}
export function cancelOrder(data, options = {}) {
    return post(API.cancelOrder, data, options);
}

export function updateOrder(data, options = {}) {
    return post(API.updateOrderById, data, options);
}

export function getProductDetail(options = {}) {
    return get(API.getProductDetailById, options);
}

export function getProductByCategory(options = {}) {
    return get(API.getProductByCategory, options);
}

// 收藏相关API
export function getFavorites(options = {}) {
    return get(API.getFavorites, options);
}

export function addFavorite(data, options = {}) {
    return post(API.addFavorite, data, options);
}

export function removeFavorite(data, options = {}) {
    return post(API.removeFavorite, data, options);
}

export function checkFavorite(productId, options = {}) {
    return get(API.checkFavorite, { 
        ...options, 
        params: { ...options?.params, id: productId } 
    });
}